<span class="glyphicon glyphicon-map-marker" aria-hidden="true">
    <span>系统</span> /
    <span>用户</span> /
    <span>修改用户信息</span>
</span>
<row>
    <div class="col-md-8 col-md-offset-2" style="margin-top: 37px;">
        <form class="form-horizontal">
            <div class="form-group">
                <label for="title" class="col-md-3 control-label">
                    <div class="text-center">用户昵称</div>
                </label>
                <div class="col-md-9">
                    <input type="text" class="form-control" id="nickname" value="{$user.nickname}"
                           name="nickname" placeholder="输入用户昵称">
                </div>
            </div>
            <div class="form-group">
                <label for="title" class="col-md-3 control-label">
                    <div class="text-center">用户账号</div>
                </label>
                <div class="col-md-9">
                    <input type="text" class="form-control" id="username" value="{$user.username}"
                           name="username" placeholder="输入用户账号" disabled="disabled">
                </div>
            </div>
            <div class="form-group">
                <label for="title" class="col-md-3 control-label">
                    <div class="text-center">用户邮箱</div>
                </label>
                <div class="col-md-9">
                    <input type="text" class="form-control" id="email" value="{$user.email}"
                           name="email" placeholder="输入用户邮箱">
                </div>
            </div>
            <div class="form-group">
                <label for="title" class="col-md-3 control-label">
                    <div class="text-center">用户手机号码</div>
                </label>
                <div class="col-md-9">
                    <input type="text" class="form-control" id="mobile" value="{$user.mobile}"
                           name="mobile" placeholder="输入用户手机号码">
                </div>
            </div>
            <div class="form-group save-btn">
                <button type="button" onclick="return getEditInfo()" >保存</button>
                <button type="button" onclick="javascript:history.back(-1);return false;" style="background: red;">取消</button>
            </div>
        </form>
    </div>
</row>
<script type="text/javascript">
    function getEditInfo() {
        var nickname = document.getElementById("nickname").value;
        if(nickname == ""){
            layer.msg('请输入您的昵称',
                {icon: 2,time: 2000,offset: 't',closeBtn: 0,shift:4});
            return false;
        }
        var email = $('input[name="email"]').val();
        if(email == ""){
            layer.msg('请输入您的邮箱号码',
                {icon: 2,time: 2000,offset: 't',closeBtn: 0,shift:4});
            return false;
        }
        var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
        if(!myreg.test(email)){
            layer.msg('您输入的邮箱号码不合法',
                {icon: 2,time: 2000,offset: 't',closeBtn: 0,shift:4});
            return false;
        }
        var mobile = $('input[name="mobile"]').val();
        if(mobile == ""){
            layer.msg('请输入您的手机号码',
                {icon: 2,time: 2000,offset: 't',closeBtn: 0,shift:4});
            return false;
        }
        var pattern=/^((13[0-9])|(15[1-3,5-9])|(17[7])|(18[0-9]))\d{8}$/;
        if(!pattern.test(mobile)){
            layer.msg('您输入的手机号码不合法',
                {icon: 2,time: 2000,offset: 't',closeBtn: 0,shift:4});
            return false;
        }
        var json = {"nickname":nickname,"email":email,"mobile":mobile};
        $.ajax({
           type:"post",
           url:"__HTTP__/User/EditInfo",
           data:json,
           success:function (res) {
               if(res.errMsg == "令牌失效"){
                   layer.msg('登录令牌失效,请重新登录',
                       {icon: 2,time: 2000,offset: 't',closeBtn: 0,shift:4});
                   setTimeout('getLogin()',3000);
                   return;
               }
               layer.msg('用户信息修改成功',
                   {icon: 1,time: 2000,offset: 't',closeBtn: 0,shift:4});
           } 
        });
    }
</script> 